import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
// import 'package:request_ruoyi/router/router.dart';
import 'package:request_ruoyi/req/home_req.dart';

class HomeScreen extends HookWidget {
  const HomeScreen({super.key});

  Future<void> getUserList() async {
    const params = {
      'pageNum': 1,
      'pageSize': 10,
      'userName': '邓紫棋',
      'phonenumber': '',
    };
    final response = await HomeReq.getUserList(params);
    debugPrint(response.toString());
  }

  @override
  Widget build(BuildContext context) {
    final counter = useState(0);

    return Scaffold(
      appBar: AppBar(title: Text('主页'), centerTitle: true),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(Icons.home, size: 100, color: Colors.blue),
            SizedBox(height: 20),
            Text(
              '欢迎来到主页',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
            ),
            SizedBox(height: 10),
            Text(
              '这是一个简单的主页界面',
              style: TextStyle(fontSize: 16, color: Colors.grey[600]),
            ),
            SizedBox(height: 20),
            Text('点击次数: ${counter.value}', style: TextStyle(fontSize: 18)),
            SizedBox(height: 10),
            ElevatedButton(
              onPressed: () => counter.value++,
              child: Text('点击我'),
            ),
            ElevatedButton(onPressed: () => getUserList(), child: Text('查看用户')),
          ],
        ),
      ),
    );
  }
}
